package cn.tedu.medicalpath.employee.controller;

import cn.tedu.medicalpath.base.response.JsonResult;
import cn.tedu.medicalpath.employee.pojo.dto.EmployeeQuery;
import cn.tedu.medicalpath.employee.pojo.dto.EmployeeSaveParam;
import cn.tedu.medicalpath.employee.pojo.entity.Employee;
import cn.tedu.medicalpath.employee.pojo.vo.EmployeeVO;
import cn.tedu.medicalpath.employee.service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/v1/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @GetMapping("select")
    public JsonResult selectEmployee(EmployeeQuery employeeQuery){
        log.debug("开始处理【查询员工信息】的请求，参数：{}",employeeQuery);
        List<EmployeeVO> list = employeeService.selectEmployee(employeeQuery);
        return JsonResult.success(list);
    }

    @PostMapping("insert")
    public JsonResult insert(EmployeeSaveParam employeeSaveParam){
        log.debug("开始处理【新增员工信息】的请求，参数：{}",employeeSaveParam);
        employeeService.insert(employeeSaveParam);
        return JsonResult.success();
    }

    @PostMapping("delete")
    public JsonResult delete(Integer id){
        log.debug("开始处理【删除员工信息】的请求，参数：{}",id);
        employeeService.delete(id);
        return JsonResult.success();
    }

}
